package main

import (
	"fmt"
	"runtime"
)

/**
设置golang运行时cpu的个数
要注意channel通道的读取问题
 */
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	c := make(chan bool, 10)
	for i := 0; i<10; i++{
		go a_go(c, i)
	}
	for i:=0; i<10; i++{
		<-c
	}
}
func a_go(c chan bool, index int){
	a := 1
	for i := 0; i<10000; i++{
		a += i
	}
	fmt.Println(index, a)
	c <- true
}